class Order < ActiveRecord::Base
  include OrderConcern
  before_create :invoke_payment

  private
  def invoke_payment
    result = WxPay::Service.invoke_unifiedorder({
                                                           body: good_name,
                                                           out_trade_no: order_no,
                                                           total_fee: (total.to_f*100).round,
                                                           spbill_create_ip: '120.55.125.107',
                                                           notify_url: 'http://shop.aidong.me/callback/wx',
                                                           trade_type: 'NATIVE',
                                                       })
    self.code_url =  result['code_url']
  end
end
